package com.xpjhs.util;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;

import org.aspectj.weaver.patterns.ThisOrTargetAnnotationPointcut;
import org.smartFramework.ri.LicenseUtils;


@SuppressWarnings("serial")
public class RIManagerContext  extends HttpServlet   {

	
	@Override
	public void service(ServletRequest arg0, ServletResponse arg1)
			throws ServletException, IOException {
		super.service(arg0, arg1);
		System.out.println(this.getServletContext().getRealPath(""));
	}

	@Override
	public ServletConfig getServletConfig() {
			return super.getServletConfig();
	}

	@Override
	public ServletContext getServletContext() {
		return super.getServletContext();
	}

	@Override
	public void init(ServletConfig config) throws ServletException {
		super.init(config);
		String webRoot = this.getServletContext().getRealPath("");
		 
	        File licenseFile = new File(webRoot+"/WEB-INF/spring/bootstart.dat");
	        try {
	            if (!LicenseUtils.checkLicense(licenseFile)){
	                System.out.println("授权已过期，请联系管理员!QQ：263235040");
	                System.exit(0);
	            }else {
					System.out.println("已授权！！！谢谢使用");
				}
	        } catch (Exception e) {
	            e.printStackTrace();
	            System.exit(0);
	        }
	    }
	
	}

	
